package net.betou.trade.main.dao.impl;

import java.util.List;


import org.springframework.stereotype.Repository;

import net.betou.common.hibernate3.Finder;
import net.betou.common.hibernate3.HibernateBaseDao;
import net.betou.trade.entity.main.RoleExt;
import net.betou.trade.main.dao.RoleExtDao;

/**
 * 查询设置
 * @author 叶装装
 *
 */
@Repository
public class RoleExtDaoImpl extends HibernateBaseDao< RoleExt, Integer >implements RoleExtDao{

	public RoleExt deleteById( Integer id ) {
		RoleExt bean = get( id );
		if( bean != null ){
			getSession( ).delete( bean );
		}
		return bean;
	}

	public RoleExt findById( Integer id ) {
		return get( id );
	}

	public RoleExt findByKey( String key ) {
		return findUniqueByProperty( "key", key );
	}

	@SuppressWarnings( "unchecked" )
	public List< RoleExt > getList( Integer roleId ) {
		String hql = " from RoleExt bean where bean.role.id=:id";
		Finder f = Finder.create( hql );
		f.setParam( "id", roleId );
		return find( f );
	}

	public RoleExt save( RoleExt bean ) {
		getSession( ).save( bean );
		return bean;
	}

	@Override
	protected Class< RoleExt > getEntityClass( ) {
		return RoleExt.class;
	}

}
